package com.guldan.thrall.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.guldan.core.controller.BaseController;
import com.guldan.core.dubbo.client.ResponseDTO;
import com.guldan.core.response.ResponseJson;
import com.guldan.jaina.dto.citizeninfo.CitizenInfoDTO;
import com.guldan.jaina.dto.citizeninfo.CitizenInfoSearchDTO;
import com.guldan.jaina.dto.registersuccess.RegisterSuccessDTO;
import com.guldan.jaina.provider.ICitizenInfoProvider;
import com.guldan.jaina.provider.IProjectRegisterProvider;

/**
 * Created by Silas.
 * Date: 2016/11/10
 * Time: 22:06
 */
@Controller
@RequestMapping("/mobile/citizen")
public class MobileCitizenInfoController extends BaseController {


    @Autowired
    private ICitizenInfoProvider iCitizenInfoProvider;

    @Autowired
    private IProjectRegisterProvider iProjectRegisterProvider;
    
    //获取单个居民信息
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    @ResponseJson
    public
    @ResponseBody
    CitizenInfoDTO get(@RequestBody CitizenInfoSearchDTO dto) {
        ResponseDTO<List<CitizenInfoDTO>> response = iCitizenInfoProvider.getCitizenInfoList(dto);
        List<CitizenInfoDTO> data = response.getData();
        if (data != null && data.size() > 0)
        	return data.get(0);
        return null;
    }

    //获取居民补贴历史记录列表
    @RequestMapping(value = "/getRegisterList", method = RequestMethod.POST)
    @ResponseJson
    public
    @ResponseBody
    List<RegisterSuccessDTO> getRegisterList(@RequestBody CitizenInfoSearchDTO dto) {
        ResponseDTO<List<RegisterSuccessDTO>> response = iProjectRegisterProvider.getRegisterList(dto);

        return response.getData();
    }


}
